package com.example.class_manage.Controller;


import com.example.class_manage.Mapper.All_HomeworkQuestion;
import com.example.class_manage.Mapper.Usermapper;
import com.example.class_manage.Util.JsonData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/")
@Slf4j
@Api(tags = "学生管理接口")
public class Student_Controller {
    @Autowired
    Usermapper usermapper;
    @Autowired
    All_HomeworkQuestion all_homeworkQuestion;

    @ApiOperation("学生更改姓名")
    @PostMapping("/updatename")
    public JsonData updatename(@RequestParam("id") int id, @RequestParam("name") String name) {
        Integer statu = 0;
        statu = usermapper.updatename(id, name);
        return statu != 0 ? JsonData.buildSuccess("更改成功") : JsonData.buildError("更改失败");

    }

    @ApiOperation("更改学生年级")
    @PostMapping("/updatesgrade")
    public JsonData updatesgrade(@RequestParam("id") int id, @RequestParam("grade") int grade) {
        Integer statu = 0;
        statu = usermapper.updatesgrade(id, grade);
        return statu != 0 ? JsonData.buildSuccess("更改成功") : JsonData.buildError("更改失败");
    }

    @ApiOperation("更改学生班级")
    @PostMapping("/updatesclass")
    public JsonData updatesclasss(@RequestParam("id") int id, @RequestParam("sclass") String sclass) {
        Integer statu = 0;
        statu = usermapper.updatesclass(id, sclass);
        return statu != 0 ? JsonData.buildSuccess("更改成功") : JsonData.buildError("更改失败");
    }


}
